
                    <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
                        <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
                    </svg>
                    <p></p> 
<div class="toc"> 
 <h4><a name="t0"></a>文章目录</h4> 
 <ul><li><a href="#_6" rel="nofollow" target="">登录认证服务以及云数据库使用</a></li><li><a href="#_12" rel="nofollow" target="">一创建登录注册页面</a></li><li><a href="#_17" rel="nofollow" target="">二、开启认证服务</a></li><li><a href="#_20" rel="nofollow" target="">二、创建数据表</a></li><li><ul><li><a href="#1_25" rel="nofollow" target="">1.导出数据表</a></li><li><a href="#2__33" rel="nofollow" target="">2.使用表 进行增删改查</a></li><li><a href="#3_203" rel="nofollow" target="">3.查看云数据库</a></li></ul> 
 </li></ul> 
</div> 
<p></p> 
<hr> 
<h2><a name="t1"></a><a id="_6"></a>登录认证服务以及云数据库使用</h2> 
<p>云端开发不需要存储token,由提供的API统一验证，假设未登录则跳转登录页，已登录 跳转首页。</p> 
<hr> 
<h2><a name="t2"></a><a id="_12"></a>一创建登录注册页面</h2> 
<p>根据上一章节写过的测试云端可使用，并且判断未登录则跳转登录页，已登录则跳转首页的逻辑，在pages目录下创建login.<a href="https://so.csdn.net/so/search?q=ets&amp;spm=1001.2101.3001.7020" target="_blank" class="hl hl-1" data-report-view="{&quot;spm&quot;:&quot;1001.2101.3001.7020&quot;,&quot;dest&quot;:&quot;https://so.csdn.net/so/search?q=ets&amp;spm=1001.2101.3001.7020&quot;,&quot;extra&quot;:&quot;{\&quot;searchword\&quot;:\&quot;ets\&quot;}&quot;}" data-report-click="{&quot;spm&quot;:&quot;1001.2101.3001.7020&quot;,&quot;dest&quot;:&quot;https://so.csdn.net/so/search?q=ets&amp;spm=1001.2101.3001.7020&quot;,&quot;extra&quot;:&quot;{\&quot;searchword\&quot;:\&quot;ets\&quot;}&quot;}" data-tit="ets" data-pretit="ets">ets</a>、register.ets、index.ets<br> <img src="https://i-blog.csdnimg.cn/direct/aac561451eb941179abe01d3424266d5.png" alt="在这里插入图片描述"></p> 
<h2><a name="t3"></a><a id="_17"></a>二、开启认证服务</h2> 
<p><img src="https://i-blog.csdnimg.cn/direct/5e47d5a74ef547a28cb3e5c1534d2d54.png" alt="在这里插入图片描述"></p> 
<h2><a name="t4"></a><a id="_20"></a>二、创建数据表</h2> 
<p><img src="https://i-blog.csdnimg.cn/direct/ebc163e534534c86b3f3d80e812be3fe.png" alt="在这里插入图片描述"><br> <img src="https://i-blog.csdnimg.cn/direct/733929c587664b2c89b8f4ed3f1e8998.png" alt="在这里插入图片描述"><br> <img src="https://i-blog.csdnimg.cn/direct/ae8d697d5d304f3788b5cf84bdff7ba3.png" alt="在这里插入图片描述"></p> 
<h3><a name="t5"></a><a id="1_25"></a>1.导出数据表</h3> 
<p>导出一个<a href="https://so.csdn.net/so/search?q=json%E6%A0%BC%E5%BC%8F&amp;spm=1001.2101.3001.7020" target="_blank" class="hl hl-1" data-report-view="{&quot;spm&quot;:&quot;1001.2101.3001.7020&quot;,&quot;dest&quot;:&quot;https://so.csdn.net/so/search?q=json%E6%A0%BC%E5%BC%8F&amp;spm=1001.2101.3001.7020&quot;,&quot;extra&quot;:&quot;{\&quot;searchword\&quot;:\&quot;json格式\&quot;}&quot;}" data-report-click="{&quot;spm&quot;:&quot;1001.2101.3001.7020&quot;,&quot;dest&quot;:&quot;https://so.csdn.net/so/search?q=json%E6%A0%BC%E5%BC%8F&amp;spm=1001.2101.3001.7020&quot;,&quot;extra&quot;:&quot;{\&quot;searchword\&quot;:\&quot;json格式\&quot;}&quot;}" data-tit="json格式" data-pretit="json格式">json格式</a>，一个js格式<br> <img src="https://i-blog.csdnimg.cn/direct/6e07be5d38874dbdba0e47b9ddf19170.png" alt="在这里插入图片描述"><br> <img src="https://i-blog.csdnimg.cn/direct/41d7f78a754e4d42a39dda6172247d39.png" alt="在这里插入图片描述"><br> 将导出的表 放到ets/db目录下<br> <img src="https://i-blog.csdnimg.cn/direct/21dec8f5155148d3bf71eb249221d6de.png" alt="在这里插入图片描述"></p> 
<h3><a name="t6"></a><a id="2__33"></a>2.使用表 进行增删改查</h3> 
<p>以下为注册页面 会详细注释 看代码</p> 
<pre data-index="0" class="set-code-show prettyprint" name="code" style="user-select: auto;"><code class="prism language-cpp has-numbering" onclick="mdcp.copyCode(event)" style="position: unset; user-select: auto;"><span class="token comment">// @ts-nocheck</span>
<span class="token comment">//引入router路由跳转</span>
<span class="token keyword">import</span> <span class="token module">router</span> from <span class="token char">'@ohos.router'</span><span class="token punctuation">;</span>
<span class="token comment">//VerifyCodeAction 为集成的验证码函数</span>
<span class="token keyword">import</span> <span class="token module">cloud</span><span class="token punctuation">,</span><span class="token punctuation">{<!-- --></span>VerifyCodeAction<span class="token punctuation">}</span> from <span class="token string">"@hw-agconnect/cloud"</span>
<span class="token comment">//配置数据库相关文件 将导出的数据表 引入  以下是页面的布局可以不用看 往下看</span>
<span class="token keyword">import</span> <span class="token module">appJSON</span> from <span class="token char">'../bd/app.json'</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{<!-- --></span>coupon<span class="token punctuation">}</span> from <span class="token char">'../bd/coupon'</span>
<span class="token keyword">import</span>  <span class="token punctuation">{<!-- --></span>userInfo<span class="token punctuation">}</span> from <span class="token char">'../bd/userInfo'</span>
@Entry
@Component
<span class="token keyword">struct</span> <span class="token class-name">Register</span> <span class="token punctuation">{<!-- --></span>
  @State message<span class="token operator">:</span>string <span class="token operator">=</span> <span class="token char">'注册'</span><span class="token punctuation">;</span>
  tel<span class="token operator">:</span>string <span class="token operator">=</span><span class="token char">''</span><span class="token punctuation">;</span>
  code<span class="token operator">:</span>string <span class="token operator">=</span> <span class="token char">''</span><span class="token punctuation">;</span>
  @State flag<span class="token operator">:</span>boolean <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
  @State num<span class="token operator">:</span>number <span class="token operator">=</span> <span class="token number">60</span><span class="token punctuation">;</span>
  @State timer<span class="token operator">:</span>any <span class="token operator">=</span> <span class="token char">''</span><span class="token punctuation">;</span> <span class="token comment">//定时器</span>
  <span class="token function">start</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{<!-- --></span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>timer <span class="token operator">=</span> <span class="token function">setInterval</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token punctuation">{<!-- --></span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>num<span class="token operator">--</span><span class="token punctuation">;</span>
      <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>num<span class="token operator">==</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">{<!-- --></span>
        <span class="token function">clearInterval</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>timer<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>flag <span class="token operator">=</span><span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>num<span class="token operator">=</span><span class="token number">60</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span><span class="token number">1000</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
  
  <span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token function">Row</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
      <span class="token function">Column</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>space<span class="token operator">:</span><span class="token number">20</span><span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token function">Image</span><span class="token punctuation">(</span>$<span class="token function">rawfile</span><span class="token punctuation">(</span><span class="token string">"icon.png"</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">width</span><span class="token punctuation">(</span><span class="token number">150</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">height</span><span class="token punctuation">(</span><span class="token number">150</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">margin</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>top<span class="token operator">:</span><span class="token number">100</span><span class="token punctuation">,</span>bottom<span class="token operator">:</span><span class="token number">50</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
        <span class="token function">TextInput</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>placeholder<span class="token operator">:</span><span class="token char">'手机号'</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
        <span class="token punctuation">.</span><span class="token function">onChange</span><span class="token punctuation">(</span>val<span class="token operator">=</span><span class="token operator">&gt;</span><span class="token punctuation">{<!-- --></span>
          <span class="token keyword">this</span><span class="token punctuation">.</span>tel<span class="token operator">=</span>val<span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span>
        <span class="token function">Row</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>space<span class="token operator">:</span><span class="token number">5</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">{<!-- --></span>
          <span class="token function">TextInput</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>placeholder<span class="token operator">:</span><span class="token char">'验证码'</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">onChange</span><span class="token punctuation">(</span>val<span class="token operator">=</span><span class="token operator">&gt;</span><span class="token punctuation">{<!-- --></span>
              <span class="token keyword">this</span><span class="token punctuation">.</span>code<span class="token operator">=</span>val<span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">width</span><span class="token punctuation">(</span><span class="token number">120</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">height</span><span class="token punctuation">(</span><span class="token number">40</span><span class="token punctuation">)</span>
          <span class="token function">Button</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>flag<span class="token operator">?</span><span class="token string">"获取验证码"</span><span class="token operator">:</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>num<span class="token operator">&gt;=</span><span class="token number">10</span><span class="token operator">?</span><span class="token keyword">this</span><span class="token punctuation">.</span>num<span class="token operator">:</span><span class="token string">"0"</span><span class="token operator">+</span><span class="token keyword">this</span><span class="token punctuation">.</span>num<span class="token punctuation">)</span><span class="token operator">+</span><span class="token string">"s后获取"</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">height</span><span class="token punctuation">(</span><span class="token number">40</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">onClick</span><span class="token punctuation">(</span> <span class="token function">async</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token punctuation">{<!-- --></span>
              <span class="token comment">//验证手机号</span>
              <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token punctuation">(</span><span class="token operator">/</span><span class="token operator">^</span><span class="token number">1</span><span class="token punctuation">[</span><span class="token number">3</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span>\d<span class="token punctuation">{<!-- --></span><span class="token number">9</span><span class="token punctuation">}</span>$<span class="token operator">/</span><span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>tel<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{<!-- --></span>
              AlertDialog<span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
                title<span class="token operator">:</span><span class="token string">"提示"</span><span class="token punctuation">,</span>
                message<span class="token operator">:</span><span class="token string">"手机号格式错误"</span><span class="token punctuation">,</span>
              <span class="token punctuation">}</span><span class="token punctuation">)</span>
                <span class="token keyword">return</span>
              <span class="token punctuation">}</span>
              <span class="token comment">//调用方法  -------------看这里</span>
              <span class="token comment">//使用requestVerifyCode函数 看送验证码</span>
              await cloud<span class="token punctuation">.</span><span class="token function">auth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">requestVerifyCode</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
                action<span class="token operator">:</span>VerifyCodeAction<span class="token punctuation">.</span>REGISTER_LOGIN<span class="token punctuation">,</span>
                lang<span class="token operator">:</span><span class="token char">'zh_ch'</span><span class="token punctuation">,</span>
                sendInterval<span class="token operator">:</span><span class="token number">60</span><span class="token punctuation">,</span>
                verifyCodeType<span class="token operator">:</span><span class="token punctuation">{<!-- --></span>
                  phoneNumber<span class="token operator">:</span><span class="token keyword">this</span><span class="token punctuation">.</span>tel<span class="token punctuation">,</span>
                  countryCode<span class="token operator">:</span><span class="token string">"86"</span><span class="token punctuation">,</span>
                  kind<span class="token operator">:</span><span class="token char">'phone'</span>
                <span class="token punctuation">}</span>
              <span class="token punctuation">}</span><span class="token punctuation">)</span>
              AlertDialog<span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
                title<span class="token operator">:</span><span class="token string">"提示"</span><span class="token punctuation">,</span>
                message<span class="token operator">:</span><span class="token string">"验证码发送成功，请注意查收"</span>
              <span class="token punctuation">}</span><span class="token punctuation">)</span>
              <span class="token comment">//按钮设置禁用状态 开始倒计时</span>
            <span class="token keyword">this</span><span class="token punctuation">.</span>flag <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
              <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">start</span><span class="token punctuation">(</span><span class="token punctuation">)</span>

            <span class="token punctuation">}</span><span class="token punctuation">)</span>
              <span class="token comment">// @ts-ignore</span>
            <span class="token punctuation">.</span><span class="token function">enabled</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>flag<span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
        <span class="token punctuation">.</span><span class="token function">width</span><span class="token punctuation">(</span><span class="token char">'100%'</span><span class="token punctuation">)</span>
        <span class="token punctuation">.</span><span class="token function">width</span><span class="token punctuation">(</span><span class="token char">'100%'</span><span class="token punctuation">)</span>
        <span class="token function">Button</span><span class="token punctuation">(</span><span class="token string">"注册"</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">width</span><span class="token punctuation">(</span><span class="token char">'100%'</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">height</span><span class="token punctuation">(</span><span class="token number">40</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">onClick</span><span class="token punctuation">(</span><span class="token function">async</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token punctuation">{<!-- --></span>
            <span class="token comment">//验证手机号和验证码</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token punctuation">(</span><span class="token operator">/</span><span class="token operator">^</span><span class="token number">1</span><span class="token punctuation">[</span><span class="token number">3</span><span class="token operator">-</span><span class="token number">9</span><span class="token punctuation">]</span>\d<span class="token punctuation">{<!-- --></span><span class="token number">9</span><span class="token punctuation">}</span>$<span class="token operator">/</span><span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>tel<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{<!-- --></span>
              AlertDialog<span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
                title<span class="token operator">:</span><span class="token string">"提示"</span><span class="token punctuation">,</span>
                message<span class="token operator">:</span><span class="token string">"手机号格式不对"</span>
              <span class="token punctuation">}</span><span class="token punctuation">)</span>
              <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token punctuation">(</span><span class="token operator">/</span><span class="token operator">^</span>\d<span class="token punctuation">{<!-- --></span><span class="token number">6</span><span class="token punctuation">}</span>$<span class="token operator">/</span><span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>code<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{<!-- --></span>
              AlertDialog<span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
                title<span class="token operator">:</span><span class="token string">"提示"</span><span class="token punctuation">,</span>
                message<span class="token operator">:</span><span class="token string">"验证码格式不对"</span>
              <span class="token punctuation">}</span><span class="token punctuation">)</span>
              <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token comment">//看这里 -----------点击注册按钮 使用 createUser函数进行注册，</span>
            <span class="token comment">//如果已经注册过了那么会返回对应的错误码，如果想重新测试在认证服务那把注册手机号删掉即可</span>
            let result <span class="token operator">=</span> await cloud<span class="token punctuation">.</span><span class="token function">auth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">createUser</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
              kind<span class="token operator">:</span> <span class="token char">'phone'</span><span class="token punctuation">,</span>
              countryCode<span class="token operator">:</span> <span class="token char">'86'</span><span class="token punctuation">,</span>
              phoneNumber<span class="token operator">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>tel<span class="token punctuation">,</span>
              verifyCode<span class="token operator">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>code
            <span class="token punctuation">}</span><span class="token punctuation">)</span>
            <span class="token comment">//获取用户对象 此时 对于云端开发而言 已经是注册成功了 并且是可以直接登录的</span>
            let user <span class="token operator">=</span> result<span class="token punctuation">.</span><span class="token function">getUser</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            let id <span class="token operator">=</span> user<span class="token punctuation">.</span><span class="token function">getUid</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">"用户id"</span><span class="token punctuation">,</span>id<span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token comment">//关联数据库</span>
          <span class="token comment">//用户信息余额</span>
          <span class="token comment">//重点来了--------------------使用表来进行新增或者修改</span>
            await cloud<span class="token punctuation">.</span><span class="token function">database</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>objectTypeInfo<span class="token operator">:</span>appJSON<span class="token punctuation">,</span>zoneName<span class="token operator">:</span><span class="token char">'charging'</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
               <span class="token comment">//选择的userInfo表</span>
              <span class="token punctuation">.</span><span class="token function">collection</span><span class="token punctuation">(</span>userInfo<span class="token punctuation">)</span>
              <span class="token comment">//如果id（主键一致那么就是修改，主键不一致就是添加）</span>
              <span class="token comment">//给新用户 添加一些余额</span>
              <span class="token punctuation">.</span><span class="token function">upsert</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
                id<span class="token punctuation">,</span>
                money<span class="token operator">:</span><span class="token char">'200'</span>
              <span class="token punctuation">}</span><span class="token punctuation">)</span>
          <span class="token comment">//优惠券</span>
          <span class="token comment">//给新用户添加一些优惠券 可以是一个或者多个</span>
            await cloud<span class="token punctuation">.</span><span class="token function">database</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>objectTypeInfo<span class="token operator">:</span>appJSON<span class="token punctuation">,</span>zoneName<span class="token operator">:</span><span class="token string">"charging"</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
            <span class="token comment">//选择coupon表</span>
              <span class="token punctuation">.</span><span class="token function">collection</span><span class="token punctuation">(</span>coupon<span class="token punctuation">)</span>
              <span class="token punctuation">.</span><span class="token function">upsert</span><span class="token punctuation">(</span><span class="token punctuation">[</span>
                <span class="token punctuation">{<!-- --></span>
                  id<span class="token operator">:</span>Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">+</span><span class="token char">'1'</span><span class="token punctuation">,</span>
                  userId<span class="token operator">:</span>id<span class="token punctuation">,</span>
                  num<span class="token operator">:</span><span class="token char">'1'</span><span class="token punctuation">,</span>
                  date<span class="token operator">:</span>Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">}</span><span class="token punctuation">,</span>
               <span class="token punctuation">{<!-- --></span>
                  id<span class="token operator">:</span>Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">+</span><span class="token char">'2'</span><span class="token punctuation">,</span>
                  userId<span class="token operator">:</span>id<span class="token punctuation">,</span>
                  num<span class="token operator">:</span><span class="token char">'2'</span><span class="token punctuation">,</span>
                  date<span class="token operator">:</span>Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">}</span>
              <span class="token punctuation">]</span><span class="token punctuation">)</span>
          <span class="token comment">// 跳转到应用首页</span>
            router<span class="token punctuation">.</span><span class="token function">replaceUrl</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
              url<span class="token operator">:</span><span class="token char">'pages/Index'</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span>
          <span class="token punctuation">}</span><span class="token punctuation">)</span>
        <span class="token function">Text</span><span class="token punctuation">(</span><span class="token char">'已有账号，去登录'</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">fontColor</span><span class="token punctuation">(</span><span class="token char">'#999999'</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">decoration</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>type<span class="token operator">:</span>TextDecorationType<span class="token punctuation">.</span>Underline<span class="token punctuation">}</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">onClick</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token punctuation">{<!-- --></span>
            router<span class="token punctuation">.</span><span class="token function">replaceUrl</span><span class="token punctuation">(</span><span class="token punctuation">{<!-- --></span>
              url<span class="token operator">:</span><span class="token char">'pages/login'</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span>
          <span class="token punctuation">}</span><span class="token punctuation">)</span>
      <span class="token punctuation">}</span>
      <span class="token punctuation">.</span><span class="token function">width</span><span class="token punctuation">(</span><span class="token char">'100%'</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token punctuation">.</span><span class="token function">margin</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<div class="hljs-button {2} add_def" data-title="复制"></div></code><ul class="pre-numbering" style="opacity: 0.887018;"><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li><li style="color: rgb(153, 153, 153);">6</li><li style="color: rgb(153, 153, 153);">7</li><li style="color: rgb(153, 153, 153);">8</li><li style="color: rgb(153, 153, 153);">9</li><li style="color: rgb(153, 153, 153);">10</li><li style="color: rgb(153, 153, 153);">11</li><li style="color: rgb(153, 153, 153);">12</li><li style="color: rgb(153, 153, 153);">13</li><li style="color: rgb(153, 153, 153);">14</li><li style="color: rgb(153, 153, 153);">15</li><li style="color: rgb(153, 153, 153);">16</li><li style="color: rgb(153, 153, 153);">17</li><li style="color: rgb(153, 153, 153);">18</li><li style="color: rgb(153, 153, 153);">19</li><li style="color: rgb(153, 153, 153);">20</li><li style="color: rgb(153, 153, 153);">21</li><li style="color: rgb(153, 153, 153);">22</li><li style="color: rgb(153, 153, 153);">23</li><li style="color: rgb(153, 153, 153);">24</li><li style="color: rgb(153, 153, 153);">25</li><li style="color: rgb(153, 153, 153);">26</li><li style="color: rgb(153, 153, 153);">27</li><li style="color: rgb(153, 153, 153);">28</li><li style="color: rgb(153, 153, 153);">29</li><li style="color: rgb(153, 153, 153);">30</li><li style="color: rgb(153, 153, 153);">31</li><li style="color: rgb(153, 153, 153);">32</li><li style="color: rgb(153, 153, 153);">33</li><li style="color: rgb(153, 153, 153);">34</li><li style="color: rgb(153, 153, 153);">35</li><li style="color: rgb(153, 153, 153);">36</li><li style="color: rgb(153, 153, 153);">37</li><li style="color: rgb(153, 153, 153);">38</li><li style="color: rgb(153, 153, 153);">39</li><li style="color: rgb(153, 153, 153);">40</li><li style="color: rgb(153, 153, 153);">41</li><li style="color: rgb(153, 153, 153);">42</li><li style="color: rgb(153, 153, 153);">43</li><li style="color: rgb(153, 153, 153);">44</li><li style="color: rgb(153, 153, 153);">45</li><li style="color: rgb(153, 153, 153);">46</li><li style="color: rgb(153, 153, 153);">47</li><li style="color: rgb(153, 153, 153);">48</li><li style="color: rgb(153, 153, 153);">49</li><li style="color: rgb(153, 153, 153);">50</li><li style="color: rgb(153, 153, 153);">51</li><li style="color: rgb(153, 153, 153);">52</li><li style="color: rgb(153, 153, 153);">53</li><li style="color: rgb(153, 153, 153);">54</li><li style="color: rgb(153, 153, 153);">55</li><li style="color: rgb(153, 153, 153);">56</li><li style="color: rgb(153, 153, 153);">57</li><li style="color: rgb(153, 153, 153);">58</li><li style="color: rgb(153, 153, 153);">59</li><li style="color: rgb(153, 153, 153);">60</li><li style="color: rgb(153, 153, 153);">61</li><li style="color: rgb(153, 153, 153);">62</li><li style="color: rgb(153, 153, 153);">63</li><li style="color: rgb(153, 153, 153);">64</li><li style="color: rgb(153, 153, 153);">65</li><li style="color: rgb(153, 153, 153);">66</li><li style="color: rgb(153, 153, 153);">67</li><li style="color: rgb(153, 153, 153);">68</li><li style="color: rgb(153, 153, 153);">69</li><li style="color: rgb(153, 153, 153);">70</li><li style="color: rgb(153, 153, 153);">71</li><li style="color: rgb(153, 153, 153);">72</li><li style="color: rgb(153, 153, 153);">73</li><li style="color: rgb(153, 153, 153);">74</li><li style="color: rgb(153, 153, 153);">75</li><li style="color: rgb(153, 153, 153);">76</li><li style="color: rgb(153, 153, 153);">77</li><li style="color: rgb(153, 153, 153);">78</li><li style="color: rgb(153, 153, 153);">79</li><li style="color: rgb(153, 153, 153);">80</li><li style="color: rgb(153, 153, 153);">81</li><li style="color: rgb(153, 153, 153);">82</li><li style="color: rgb(153, 153, 153);">83</li><li style="color: rgb(153, 153, 153);">84</li><li style="color: rgb(153, 153, 153);">85</li><li style="color: rgb(153, 153, 153);">86</li><li style="color: rgb(153, 153, 153);">87</li><li style="color: rgb(153, 153, 153);">88</li><li style="color: rgb(153, 153, 153);">89</li><li style="color: rgb(153, 153, 153);">90</li><li style="color: rgb(153, 153, 153);">91</li><li style="color: rgb(153, 153, 153);">92</li><li style="color: rgb(153, 153, 153);">93</li><li style="color: rgb(153, 153, 153);">94</li><li style="color: rgb(153, 153, 153);">95</li><li style="color: rgb(153, 153, 153);">96</li><li style="color: rgb(153, 153, 153);">97</li><li style="color: rgb(153, 153, 153);">98</li><li style="color: rgb(153, 153, 153);">99</li><li style="color: rgb(153, 153, 153);">100</li><li style="color: rgb(153, 153, 153);">101</li><li style="color: rgb(153, 153, 153);">102</li><li style="color: rgb(153, 153, 153);">103</li><li style="color: rgb(153, 153, 153);">104</li><li style="color: rgb(153, 153, 153);">105</li><li style="color: rgb(153, 153, 153);">106</li><li style="color: rgb(153, 153, 153);">107</li><li style="color: rgb(153, 153, 153);">108</li><li style="color: rgb(153, 153, 153);">109</li><li style="color: rgb(153, 153, 153);">110</li><li style="color: rgb(153, 153, 153);">111</li><li style="color: rgb(153, 153, 153);">112</li><li style="color: rgb(153, 153, 153);">113</li><li style="color: rgb(153, 153, 153);">114</li><li style="color: rgb(153, 153, 153);">115</li><li style="color: rgb(153, 153, 153);">116</li><li style="color: rgb(153, 153, 153);">117</li><li style="color: rgb(153, 153, 153);">118</li><li style="color: rgb(153, 153, 153);">119</li><li style="color: rgb(153, 153, 153);">120</li><li style="color: rgb(153, 153, 153);">121</li><li style="color: rgb(153, 153, 153);">122</li><li style="color: rgb(153, 153, 153);">123</li><li style="color: rgb(153, 153, 153);">124</li><li style="color: rgb(153, 153, 153);">125</li><li style="color: rgb(153, 153, 153);">126</li><li style="color: rgb(153, 153, 153);">127</li><li style="color: rgb(153, 153, 153);">128</li><li style="color: rgb(153, 153, 153);">129</li><li style="color: rgb(153, 153, 153);">130</li><li style="color: rgb(153, 153, 153);">131</li><li style="color: rgb(153, 153, 153);">132</li><li style="color: rgb(153, 153, 153);">133</li><li style="color: rgb(153, 153, 153);">134</li><li style="color: rgb(153, 153, 153);">135</li><li style="color: rgb(153, 153, 153);">136</li><li style="color: rgb(153, 153, 153);">137</li><li style="color: rgb(153, 153, 153);">138</li><li style="color: rgb(153, 153, 153);">139</li><li style="color: rgb(153, 153, 153);">140</li><li style="color: rgb(153, 153, 153);">141</li><li style="color: rgb(153, 153, 153);">142</li><li style="color: rgb(153, 153, 153);">143</li><li style="color: rgb(153, 153, 153);">144</li><li style="color: rgb(153, 153, 153);">145</li><li style="color: rgb(153, 153, 153);">146</li><li style="color: rgb(153, 153, 153);">147</li><li style="color: rgb(153, 153, 153);">148</li><li style="color: rgb(153, 153, 153);">149</li><li style="color: rgb(153, 153, 153);">150</li><li style="color: rgb(153, 153, 153);">151</li><li style="color: rgb(153, 153, 153);">152</li><li style="color: rgb(153, 153, 153);">153</li><li style="color: rgb(153, 153, 153);">154</li><li style="color: rgb(153, 153, 153);">155</li><li style="color: rgb(153, 153, 153);">156</li><li style="color: rgb(153, 153, 153);">157</li><li style="color: rgb(153, 153, 153);">158</li><li style="color: rgb(153, 153, 153);">159</li><li style="color: rgb(153, 153, 153);">160</li><li style="color: rgb(153, 153, 153);">161</li><li style="color: rgb(153, 153, 153);">162</li><li style="color: rgb(153, 153, 153);">163</li><li style="color: rgb(153, 153, 153);">164</li><li style="color: rgb(153, 153, 153);">165</li></ul><button class="btn-code-notes mdeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:0,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:0,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<h3><a name="t7"></a><a id="3_203"></a>3.查看云数据库</h3> 
<p><img src="https://i-blog.csdnimg.cn/direct/76ce5a22b4fa40ef936fa87ce99225a1.png" alt="在这里插入图片描述"></p>
                